use crate::args::BmbpArgs;
use crate::upload::upload_pom;
use crate::walk::walk_pom_lib;
use std::env;
use std::env::consts::OS;

mod args;
mod upload;
mod walk;

fn main() {
    println!("运行在:{}", OS.to_string());
    let cmd_args = env::args();
    let args_rs = BmbpArgs::new(cmd_args);
    if args_rs.is_err() {
        println!("===>error:{}", args_rs.err().unwrap());
        return;
    }

    let args = args_rs.unwrap();
    let valid_rs = args.valid();
    if valid_rs.is_err() {
        println!("===> valid error:{}", valid_rs.err().unwrap());
        return;
    }

    // 读取 仓库路径
    let pom_lib_rs = walk_pom_lib(&args.local, &args.local_type);
    if pom_lib_rs.is_err() {
        println!("===> read load lib error:{}", pom_lib_rs.err().unwrap());
        return;
    }

    let up_rs = upload_pom(&args, pom_lib_rs.unwrap().as_slice());
    if up_rs.is_err() {
        println!("===> upload error:{}", up_rs.err().unwrap());
        return;
    }
}
